{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "source": [
    "import torch\n",
    "import numpy as np\n",
    "from torch import nn\n",
    "from torch.nn import init\n",
    "import matplotlib.pyplot as plt\n",
    "import sys\n",
    "import torchvision\n",
    "from torchvision import transforms\n",
    "sys.path.append('..')\n",
    "import IPython.display as display"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "source": [
    "batch_size=2048\n",
    "mnist_train=torchvision.datasets.FashionMNIST(root='~/Datasets/FashionMNIST',train=True,download=True,transform=transforms.ToTensor())\n",
    "mnist_test=torchvision.datasets.FashionMNIST(root='~/Datasets/FashionMNIST',train=True,download=True,transform=transforms.ToTensor())\n",
    "\n",
    "device=torch.device('cuda' if torch.cuda.is_available() else 'cpu') # cuda加速\n",
    "# print(device)\n",
    "mnist_train.data.to(device)\n",
    "mnist_train.targets.to(device)\n",
    "# mnist_train.class_to_idx.to(device)\n",
    "# help(mnist_train)\n",
    "# print(mnist_train.class_to_idx)\n",
    "# print(mnist_train.data)\n",
    "mnist_test.data.to(device) # ! 转化为cuda  ，dataset类中 data保存着tensor的原始数据\n",
    "mnist_test.targets.to(device)\n",
    "print(mnist_test.data.device)\n",
    "train_iter=torch.utils.data.DataLoader(mnist_train,pin_memory=True,batch_size=batch_size,shuffle=True,num_workers=8)\n",
    "test_iter=torch.utils.data.DataLoader(mnist_test,pin_memory=True,batch_size=batch_size,shuffle=True,num_workers=8) # 多线程\n"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stderr",
     "text": [
      "/home/david/anaconda3/envs/torch/lib/python3.6/site-packages/torchvision/datasets/mnist.py:498: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at  /opt/conda/conda-bld/pytorch_1631630866422/work/torch/csrc/utils/tensor_numpy.cpp:180.)\n",
      "  return torch.from_numpy(parsed.astype(m[2], copy=False)).view(*s)\n"
     ]
    },
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "cpu\n"
     ]
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "num_inputs,num_outputs,num_hiddens=784,10,256\n",
    "\n",
    "net=nn.Sequential(\n",
    "    \n",
    ")"
   ],
   "outputs": [],
   "metadata": {}
  }
 ],
 "metadata": {
  "orig_nbformat": 4,
  "language_info": {
   "name": "python",
   "version": "3.6.8",
   "mimetype": "text/x-python",
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "pygments_lexer": "ipython3",
   "nbconvert_exporter": "python",
   "file_extension": ".py"
  },
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.6.8 64-bit ('torch': conda)"
  },
  "interpreter": {
   "hash": "2b23fc4612d2a20491382ea15c73e42619afc437d67ed04c4074dd835ed863ea"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}